//
//  CJAssetDistributionCell.m
//  Boss
//
//  Created by admin on 2018/9/18.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "CJAssetDistributionCell.h"
#import "DVPieChart.h"
#import "DVFoodPieModel.h"

@interface CJAssetDistributionCell()


@property (strong, nonatomic) IBOutlet UIView *pieView;

@property (strong, nonatomic) IBOutlet UILabel *allPriceLabel;


@end


@implementation CJAssetDistributionCell





-(void)setAllPrice:(NSString *)allPrice
{
    _allPrice = allPrice;
    self.allPriceLabel.text = [NSString stringWithFormat:@"%.2f",allPrice.floatValue/1000.0];
}
-(void)setProperty:(CJAssetsProperty *)property
{
    _property = property;
    
    CGFloat width = [UIScreen mainScreen].bounds.size.width-20;
    
    DVPieChart *chart = [[DVPieChart alloc] initWithFrame:CGRectMake(0, 0, width, 265)];
    
    [self.pieView addSubview:chart];
    
    
    DVFoodPieModel *model1 = [[DVFoodPieModel alloc] init];
    
    model1.rate = property.packetAmount.floatValue/self.allPrice.floatValue;
    model1.name = @"红包收益";
    model1.value = property.packetAmount.floatValue/1000.0;
    
    
    DVFoodPieModel *model2 = [[DVFoodPieModel alloc] init];
    
    model2.rate = property.inviteAmount.floatValue/self.allPrice.floatValue;
    model2.name = @"邀请收益";
    model2.value = property.inviteAmount.floatValue/1000.0;
    
    
    DVFoodPieModel *model3 = [[DVFoodPieModel alloc] init];
    
    model3.rate = property.transferAmount.floatValue/self.allPrice.floatValue;
    model3.name = @"转发收益";
    model3.value = property.transferAmount.floatValue/1000.0;
    
    
    DVFoodPieModel *model4 = [[DVFoodPieModel alloc] init];
    
    model4.rate = property.relationAmount.floatValue/self.allPrice.floatValue;
    model4.name = @"人脉收益";
    model4.value = property.relationAmount.floatValue/1000.0;

    NSArray *dataArray = @[model1, model2, model3, model4];
    //    NSArray *dataArray = @[model1, model2, model3, model4, model5, model6];
    
    chart.dataArray = dataArray;
    
    chart.title = @"";
    
    [chart draw];
    
    
    
    
    
    
    
    
    
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    [self setUpUI];
    // Initialization code
}
-(void)setUpUI
{
    
    
    
    
    
    
    
    
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
